package org.exteen.tag.core;

import org.exteen.exec.ExteenContext;
import org.exteen.exec.Tag;
import org.exteen.output.ExteenStream;
import org.exteen.output.FlatExteenStream;
import org.exteen.output.FlatExteenStream.TrimType;

public class FlatStreamFormattingTag extends Tag {

    private final TrimType trimType;

    public FlatStreamFormattingTag(FlatExteenStream.TrimType trimType) {
        this.trimType = trimType;
    }

    public final void doTag(ExteenContext ctx, ExteenStream stream) {

        stream.flush();

        FlatExteenStream myStream = new FlatExteenStream(stream);
        myStream.setTrimType(trimType);

        super.doBody(ctx, myStream);
        myStream.flush();
    }
}